package com.zyl.longpicturebackend.common;

import com.zyl.longpicturebackend.exception.ErrorCode;

public class ResultUtils {

    // ==========成功响应=================
    public static BaseResponse success() {
        return new BaseResponse(ErrorCode.OK);
    }

    public static BaseResponse success(String message) {
        return new BaseResponse(ErrorCode.OK.getCode(), message);
    }

    public static <T> BaseResponse<T> success(T data) {
        return new BaseResponse<T>(ErrorCode.OK.getCode(), data);
    }

    public static <T> BaseResponse<T> success(T data, String message) {
        return new BaseResponse<T>(ErrorCode.OK.getCode(), data, message);
    }

    // ==========异常（失败）响应=================

    public static BaseResponse error() {
        return new BaseResponse(ErrorCode.OPERATION_ERROR);
    }

    public static BaseResponse error(ErrorCode errorCode) {
        return new BaseResponse(errorCode);
    }

    public static BaseResponse error(int code, String message) {
        return new BaseResponse(code, message);
    }

    public static BaseResponse error(ErrorCode errorCode, String message) {
        return new BaseResponse(errorCode.getCode(), message);
    }


}
